package com.marvels.product.param.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.marvels.common.constants.MarvelsConstant;
import com.marvels.common.utils.CacheUtils;
import com.marvels.product.param.dao.McptCustomerTypeParamDao;
import com.marvels.product.param.dto.CascadeChannelDto;
import com.marvels.product.param.dto.McptCustomerTypeParamDTO;
import com.marvels.product.param.service.McptCustomerTypeParamApi;
import com.marvels.product.productmanage.dto.McptChannelDto;

@Service
public class McptCustomerTypeParamImpl implements McptCustomerTypeParamApi{

	@Autowired
	private McptCustomerTypeParamDao  typeParamDao;
	
	@Override
	public McptCustomerTypeParamDTO selectTypeById(String customerType) {
		return typeParamDao.selectTypeById(customerType);
	}

	@Override
	public List<McptCustomerTypeParamDTO> selectAllType() {
		
		String redisKey=MarvelsConstant.MCPT_CUSTOMER_TYPE_LIST_KEY;
		List<McptCustomerTypeParamDTO> list=new ArrayList<McptCustomerTypeParamDTO>();
		Object object=CacheUtils.getCacheObject(redisKey);
		if(object!=null && object instanceof List){
			list=(List<McptCustomerTypeParamDTO>)object;
		}
		if(CollectionUtils.isEmpty(list)){
			list=typeParamDao.selectAllType();
			CacheUtils.cacheObject(redisKey, list);
		}
		return list;
	}

}
